Become a Bayesian in
10 minutes

Follow along

m-clark.github.io/workshops/bayesian

\[ p(\mathrm{hypothesis}|\mathrm{data}) = \frac{p(\mathrm{data}|\mathrm{hypothesis})p(\mathrm{hypothesis})}{p(\mathrm{data})} \]

\[ \mathrm{posterior} \propto \mathrm{data} * \mathrm{prior}\]

Distributions

The goal is a distribution for a parameter (stable)…

rather than a single parameter estimate

Posterior

Posterior distribution

A weighted combination of the prior and likelihood

Prior

Represents our intution regarding the intial state of affairs

Based on:

Prior belief

Prior research

Known approaches that work well in the modeling context

The prior is subjective?!?

Subjective != Arbitrary

For example…

Subjective

Choosing a normal distribution for the likelihood

Subjective

Setting a prior variance to some value

Arbitrary

Setting your null hypothesis parameter value to 0

Arbitrary

Choosing .05 as a cutoff for ‘significance’

Perks: Probabilities

Which interpretation do you prefer?

If I asssume a value of zero for the parameter, what is the probability of my observed parameter or more extreme?

Or

What’s the probability my result is greater than zero?

Perks: Intervals

Which interpretation do you prefer?

If I repeat this study precisely an infinite number of times, and I calculate a P% interval each time, then P% of those intervals will contain the true parameter. Here is one of those intervals.

Or

The probability the parameter falls in this interval is P.

Perks

Intuitive results

Auto-regularization

  • Guards against overfitting

Intervals for anything you can calculate

Which of the following is R code for
the Bayesian model?

(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)

Which of the following is R code for
the Bayesian model?

lm(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)
(mpg ~ wt, data=mtcars)

Which of the following is R code for
the Bayesian model?

lm(mpg ~ wt, data=mtcars)
stan_lm(mpg ~ wt, data=mtcars)   # rstanarm
(mpg ~ wt, data=mtcars)

Which of the following is R code for
the Bayesian model?

lm(mpg ~ wt, data=mtcars)
stan_lm(mpg ~ wt, data=mtcars)   # rstanarm
brm(mpg ~ wt, data=mtcars)       # brms

Logistic Regression

glm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')
stan_glm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')   # rstanarm
brm(treat ~ educ + black + hisp + married, data=lalonde, family='binomial')        # brms

Ordinal Regression

clm(rating ~ temp*contact, data = wine)                       # ordinal
stan_polr(rating ~ temp*contact, data = wine)                 # rstanarm
brm(rating ~ temp*contact, data = wine, family='ordinal')     # brms

Mixed Model

lmer(Reaction ~ Days + (1 + Days|Subject))        # lme4
stan_lmer(Reaction ~ Days + (1 + Days|Subject))   # rstanarm
brm(Reaction ~ Days + (1 + Days|Subject))         # brms

The Point
















{data}

RStan and associated packages make it easy to be a Bayesian

Things you’ll need
to learn

Settings

Debugging

Diagnostics

Model comparison

Issues

Big data

Very complex models

Indoctrination commencing…

Hold please…

Bayesian Bliss

Join Now!

Can you do any less?!

Go and do likewise!